<%@page import="edu.cmu.aes.project2.SupplierService"%>
<%
	request.setAttribute("title", "Main page");
	String errorMessage = "";
	boolean isError = false;
	SupplierService service = new SupplierService(); 
	String[] brands = service.getBrands();
	if(brands == null || brands.length==0){
		errorMessage = "Brands are not found";
		isError = true;
	}
%>
<%@include file='/WEB-INF/template/header.jsp'%>
<%@include file='/WEB-INF/template/right-menu.jsp'%>
<script type="text/javascript">
	function gotoModel(brandName){
		$("#brandName").val(brandName);
		$("#redirect_form").submit();
	}
</script>
<form name="redirect_form" id="redirect_form" action="models.jsp" method="post">
	<input type="hidden" name="brandName" id="brandName" value="">
</form>
<div id="content">
Hello Biker!!! <br/>
<br/>
<% if(isError){ %>
	<font class='error'><%=errorMessage %></font>
<% }else{ %>
Please select brand we have below <br/>
<br/>
<%
	for(String brand : brands){
		out.println("<a href=\"javascript:gotoModel('"+brand+"')\">");	
		out.println(brand);
		out.println("</a>");
		out.println("<br/>");
	}
%>
<% } %>
</div>
<%@include file='/WEB-INF/template/footer.jsp'%>
